//
//  UserBSGetUserInfo.m
//  Teacher
//
//  Created by 马腾飞 on 15/8/3.
//  Copyright (c) 2015年 xueyinyue. All rights reserved.
//

#import "UserBSGetUserInfo.h"
#import "ApplicationContext.h"
#import "ApiConfig.h"
#import "User.h"

@implementation UserBSGetUserInfo

- (id)onExecute
{        
    NSDictionary *params = @{@"token":[ApplicationContext instance].token,@"versionCode":kVersionCode,@"systemType":kSystemType};
    
    id result = [self remoteJSON:@"POST" url:[ApiConfig urlApiGetUserInfo] params:params];
    
    UserBSGetUserInfoResult *serviceResult = [[UserBSGetUserInfoResult alloc] init];
    
    NSNumber *returnState = result[@"error"];
    //成功时进行注册
    if ([returnState isEqualToNumber:@0]) {
        serviceResult.isSuccess = YES;
        NSLog(@"获取用户信息成功！%@",result[@"data"]);
        [ApplicationContext instance].currentUser = [User userWithDic:result[@"data"]];
    }
    else
    {
        serviceResult.isSuccess = NO;
        serviceResult.message = result[@"msg"];
    }
    
    return serviceResult;
}

@end

@implementation UserBSGetUserInfoResult

@end